﻿using UnityEngine;

[ExecuteInEditMode, ImageEffectAllowedInSceneView]
public class HeatFlowEffect : MonoBehaviour
{
    private Material mat;
    [Range(0.01f, 0.1f)]
    public float flowStrength = 0.02f;
    [Range(0.1f, 1f)]
    public float flowSpeed = 0.5f;

    public Texture noiseTex;

    private void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        if (mat == null)
        {
            mat = new Material(Shader.Find("Custom/HeatFlow"));
            mat.SetTexture("_NoiseTex", noiseTex);
        }

        mat.SetFloat("_FlowStrength", flowStrength);
        mat.SetFloat("_FlowSpeed", flowSpeed);
        Graphics.Blit(source, destination, mat);
    }
}
